草庐IT

sqlite - Symfony2 : Unit testing with sqlite

全部标签

php - symfony2 项目上的 Swiftmailer 附件错误(无法打开文件进行阅读)

我正在开发一个symfony项目,我有一个必须使用swiftmailer发送邮件的表单。对于解释->用户可以在表单的可选文件上传功能中使用附件。(表格像命令一样保存在bdd中,提交表格后我们进行了回顾,并且发送了3封邮件(我们每次都不使用附件的两封邮件,只有带附件选项的邮件失败了有一个文件要加入,否则如果我们只使用评论(其他字段可选,像路径一样工作,邮件正在工作)我希望我的解释清楚易懂,我的英语并不完美,功能也不太容易。由于某些信息的secret性,我在这里只写了与邮件有关的代码,但如果我忘记了什么,请告诉我,我会更新帖子。当我发送一个没有附件的邮件时,我没有遇到任何问题,但是当我尝试

php - Symfony 实体类型中的树结构

我的table是这样的categories:-id-name-parent在我的表单中,您可以选择多个类别。我将此代码用于表单生成器->add('categories',EntityType::class,['class'=>'AppBundle:CourseCategory','choice_label'=>function(CourseCategory$category){return\AppBundle\Helper::categoryIndent($category).''.$category->getName();},'multiple'=>true,'expanded'=>

php - SQLite : GROUP BY without Aggregate

我试图了解GROUPBY在SQLitev2.8.17上的一个奇怪行为代码如下:_db->prepare('SELECTCOUNT(*)AScFROM(SELECTMAX(groupCode)FROMdocsGROUPBYgroupCode)');$selectQuery=$this->_db->prepare('SELECTCOUNT(*)AScFROM(SELECTgroupCodeFROMdocsGROUPBYgroupCode)');$selectMaxQuery->exec();$selectQuery->exec();var_dump($selectMaxQuery->fet

php - Symfony2 404 错误 : Object Not Found (ParamConverter error)

我创建了一个名为search.html.twig的新边界类,但是当我转到URL(http://localhost:8000/shrubs/search)时,出现以下错误:ERROR-UncaughtPHPExceptionSymfony\Component\HttpKernel\Exception\NotFoundHttpException:"AppBundle\Entity\Shrubsobjectnotfound."atC:\Users\rosmith\shrub_search\vendor\sensio\framework-extra-bundle\Request\ParamCo

php - Symfony 2.8 注入(inject) Twig

预注:我正在从Drupal7背景学习Symfony。我已经创建了一个自定义模型(虽然我认为它们在Symfony中被称为服务,据我所知),并希望它通过twig将数组呈现为变量。我找到了这个链接,并认为这种注入(inject)方法可以解决问题:http://symfony.com/doc/2.8/service_container.html可悲的是,我遇到了以下错误:Typeerror:Argument1passedtoAppBundle\Model\Newsletter::__construct()mustbeaninstanceofAppBundle\Model\Twig_Enviro

php - Symfony 3.3 从 3.2 : Compile Error: Cannot declare class Symfony\Bundle\SecurityBundle\Security\FirewallMap

自从我从symfony3.2更新到3.3后我遇到了一些问题,我得到了这个错误CompileError:CannotdeclareclassSymfony\Bundle\SecurityBundle\Security\FirewallMap,becausethenameisalreadyinuseinclasses.php(line1709)inClassCollectionLoader.php(line99)atClassCollectionLoader::load()inKernel.php(line428)atKernel->doLoadClassCache()inKernel.p

php - 仅在自定义验证器字段上需要 Symfony 表单

我正在努力寻找一种方法来使required只有那些附加了我自己的自定义验证器的字段。有什么办法可以做到这一点?/***@varstring*@ORM\Column(type="string",length=255)*@AdminAssert\CustomNotBlank(//所以在上面的例子中只有$name必须有'required'=>true,因为它是由我自己的验证器CustomNotBlank验证的.并且无论他们有什么其他验证设置,没有没有这个验证器的字段。FormType并不重要,因为我有很多表单类型的字段(这只是两个文本类型字段的简单示例) 最佳答案

php - 如果在 Symfony 中选中了复选框,则关闭表单类型的验证

我正在尝试创建一个包含付款和送货地址的地址表。选中送货地址上的复选框后,我想跳过对该地址进行的表单验证。我已经创建了下面的表单类型,其中包含一个切换选项,该选项将显示和处理复选框,但是即使选中,表单仍然有效。Symfony有documentationonhowtoimplementsuchaform,即使我几乎拥有完全相同的代码,但在检查时不会关闭验证。我没有使用验证组,所以我只是禁用默认组以禁用对实体的验证。AddressType为Address类构建表单(它对某些字段有注释约束,如NotBlank和Callback).classAddressTypeextendsAbstractT

php - 创建资源 : [message] fopen(): Unable to find the wrapper "https" on Ubuntu using Symfony 时出错

我正在尝试在Ubuntu17.04机器上安装Symfony3,但出现错误:[GuzzleHttp\Ring\Exception\RingException]Errorcreatingresource:[message]fopen():Unabletofindthewrapper"https"-didyouforgettoenableitwhenyouconfiguredPHP?[file]phar:///usr/local/bin/symfony/vendor/guzzlehttp/ringphp/src/Client/StreamHandler.php[line]406[messag

php - 如何对 Symfony Controller 进行单元测试

我正在尝试使用Codeception在测试工具中获取SymfonyController。每个方法开始如下:publicfunctionsaveAction(Request$request,$id){//Entitymanagement/**@varEntityManager$em*/$em=$this->getDoctrine()->getManager();/*Actualcodehere...*/}publicfunctionsubmitAction(Request$request,$id){//Entitymanagement/**@varEntityManager$em*/$e